package com.clive.xxweb.controller;

import com.clive.xxweb.bean.DishCategory;
import com.clive.xxweb.service.DishCategoryService;
import com.clive.xxweb.vo.DishResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/dishCategory")
public class DishCategoryController {
//    spring的依赖注入  从spring容器中把接口的唯一子类拿出来作为参数赋值给接口
    @Autowired
    private DishCategoryService dishCategoryService;
    @RequestMapping("/all")
    public DishResult findDishCategoryAll(){
        List<DishCategory> list = dishCategoryService.findDishCategoryAll();
        return DishResult.ok().data("list",list);
    }
    @RequestMapping("/delete/{id}")
    public DishResult deleteDishCategoryById(@PathVariable Integer id){
        int count = dishCategoryService.deleteDishCategoryById(id);
        return DishResult.ok().data("count",count);
    }
}
